package com.springboot.mybatis.service.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author sunyt31481
 * @date 2020/8/12 11:35
 * @description work queue的消息传递方式
 */
public class ProduceWorkDemo {
    public static void main(String[] args)throws IOException,TimeoutException {
        Connection connect = RabbitMqUtil.getConnect();
        Channel channel = connect.createChannel();
        channel.queueDeclare("helloWork",true,false,false,null);
        for (int i=0;i<10;i++){
            channel.basicPublish("", "helloWork",null, (i+"hello Work").getBytes());
        }
        RabbitMqUtil.closeConnect(channel, connect);
    }

}
